package com.sdjzu.wangfuying.disableautobrightness.base;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import androidx.annotation.Nullable;

@SuppressLint("Registered")
public class BaseService extends Service {
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return new LocalBinder();
    }

    public abstract static class ServiceConnection implements android.content.ServiceConnection {
        private boolean bind = false;

        public boolean isBind() {
            return bind;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            onServiceConnected(name, ((LocalBinder) service).getService());
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {

        }

        public abstract void onServiceConnected(ComponentName name, BaseService service);

    }

    public class LocalBinder extends Binder {
        public BaseService getService() {
            return BaseService.this;
        }

    }
}
